package com.google.code.guava.beans;

/**
 * Base functionality for Bean Properties.
 * 
 * @author Sean Patrick Floyd (<a
 *         href="mailto:sfloyd@mytoys.de">sfloyd@mytoys.de</a>)
 */
public abstract class BaseProperty<T> {

    /**
     * Sub-class from this package only.
     */
    BaseProperty(){}

    /**
     * Return the bean property name. This name can never be null or empty, and
     * it will only contain valid java identifier characters as identified by
     * {@link Character#isJavaIdentifierPart(char)}.
     */
    public abstract String getName();

    /**
     * Is this property readable? (If not, {@link #isWriteOnly()} will always
     * return true}).
     */
    public abstract boolean isReadable();

    /**
     * This is the type of the property.
     */
    public abstract Class<T> getType();

    /**
     * Is this property writeable? (If not, {@link #isReadOnly()} will always
     * return true}).
     */
    public abstract boolean isWriteable();

    /**
     * Is this property read-only? (If so, {@link #isReadable()} will return
     * true and {@link #isWriteable()} will return false}).
     */
    public final boolean isReadOnly(){
        return !isWriteable();
        // every property is either readable or writeable or both
    }

    /**
     * Is this property write-only? (If so, {@link #isWriteable()} will return
     * true and {@link #isReadable()} will return false}).
     */
    public final boolean isWriteOnly(){
        return !isReadable();
        // every property is either readable or writeable or both
    }

}
